package com.example.demo;

import com.example.demo.bean.HelloWorld;
import com.example.demo.service.impl.DatabaseAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.devtools.RemoteSpringApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

//@EnableAutoConfiguration    //Spring上下文的自动化配置,包含@Configuration
//@ComponentScan
@SpringBootApplication  //等价于使用 @Configuration,@EnableAutoConfiguration,@ComponentScan
@RestController
public class DemoApplication {

    @Autowired
    private DatabaseAccountService databaseAccountService;

    public static void main(String[] args) {
        //禁用自动重新启动应用(类加载)
        System.setProperty("spring.devtools.restart.enabled", "false");

        RemoteSpringApplication.main(new String[]{"http://localhost:8009"});
//        SpringApplication.run(DemoApplication.class, args);
    }

    @RequestMapping("/")
    String home() {
        System.out.println("访问Hello World 成功!");
        return "Hel11lo World!";
    }

    @RequestMapping("/add")
    String add() {
        databaseAccountService.add();
        return "进入add() 方法！";
    }

    @RequestMapping("/devtools")
    String testDevtools() {
        HelloWorld.testDevTools();
        return "测试spring-boot-devtools工具类";
    }
}
